<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item label="工单编号" prop="wxCode">
        <el-input
          v-model="queryParams.wxCode"
          placeholder="请输入工单编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
         <el-form-item label="维修站名称" prop="wxCode">
        <el-input
          v-model="queryParams.wxCode"
          placeholder="请输入维修站名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="车牌号" prop="wxUnit">
        <el-input
          v-model="queryParams.wxCode"
          placeholder="请输入车牌号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="车架号" prop="wxUnit">
        <el-input
          v-model="queryParams.wxCode"
          placeholder="请输入车架号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="发动机号" prop="wxUnit">
        <el-input
          v-model="queryParams.wxCode"
          placeholder="请输入发动机号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
       <el-form-item label="燃料类型" prop="wxUnit">
        <el-input
          v-model="queryParams.wxCode"
          placeholder="请输入燃料类型"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="营运类型" prop="wxUnit">
        <el-input
          v-model="queryParams.wxCode"
          placeholder="请输入营运类型"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="车辆类型" prop="wxUnit">
        <el-input
          v-model="queryParams.wxCode"
          placeholder="请输入车辆类型"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="所属地区" prop="wxUnit">
        <el-input
          v-model="queryParams.wxCode"
          placeholder="请输入所属地区"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工单创建日期" prop="wxUnit">
        <el-date-picker
          v-model="dateRange"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-download"
          size="mini"
          v-hasPermi="['car:sitem:export']"
          @click="exportData"
        >导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-s-grid"
          size="mini"
          v-hasPermi="['car:sitem:exportAll']"
          @click="exportDataAll"
        >导出全部</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table border show-summary v-loading="loading" :data="dataList">
      <el-table-column label="序号"  width="50px" align="center" type="index" />
      <el-table-column label="站点名称" align="center" prop="siteName" />
      <el-table-column label="所属地区" align="center" prop="orgcodeName" />
      <el-table-column label="维修总数" align="center" prop="totalCount" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
import { listStatistics } from "@/api/car/statisticssitem";
import { sitemNameSearch } from '@/api/vehicleserviceapproval/statisticssitem'

export default {
  name: "index",
  data() {
    return {
      siteNames:[],
      options: [],
      dataList: [],
      // 遮罩层
      loading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        siteName: null,
        startTime: null,
        endTime: null,
        orgmCode: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created(){
    // this.getList();
  },
  methods: {
    orgCodeChange(){
      sitemNameSearch(this.queryParams).then(res => {
        this.siteNames = res.data;
        console.log(this.siteNames)
      })
    },
    resetQuery(){
      this.queryParams.siteName = null;
      this.queryParams.startTime = null;
      this.queryParams.endTime = null;
      this.queryParams.orgCode = null;
    },
    exportData(){
      this.download('/car/sitem/exportdata', {
          ...this.queryParams
      }, `post_${new Date().getTime()}.xlsx`)
    },
    exportDataAll(){
      this.download('/car/sitem/exportdata/all', {
          ...this.queryParams
      }, `post_${new Date().getTime()}.xlsx`)
    },
    /** 查询汽车检测-检测站列表 */
    getList() {
      this.loading = true;
      listStatistics(this.queryParams).then(response => {
        this.dataList = response.data.list;
        this.total = response.data.total;
        this.options = response.data.treeList;
        this.loading = false;
      });
    },
    handleQuery(){
      this.queryParams.pageNum = 1;
      this.getList();
    }
  }
}
</script>

<style scoped>

</style>
